package com.ncloud.msg.mapper;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by shiqiang on 2017/5/16.
 */
public class MapRowMapper implements RowMapper {
    @Override
    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
        Map<String,Object> map = new HashMap<String,Object>();
        ResultSetMetaData  metaData = resultSet.getMetaData();
        for(int j=1;i<=metaData.getColumnCount();j++){
            map.put(metaData.getColumnName(j).toUpperCase(),  resultSet.getObject(j));
        }
        return map;
    }
}
